//
//  CAnAlgSkinTempAsleep.m
//  CareRing
//
//  Created by  on 2024/9/25.
//

#import "CAnAlgSkinTempAsleep.h"

@implementation CAnAlgSkinTempAsleep

-(NSNumber *)dataTimeStamp
{
    return @(self.daTimeStamp);
}
-(instancetype)initWith:(NSData *)data;
{
    if (self = [super init]) {
//        self.timeStamp = ts;
//        self.skinTempValue = @((skinByte + 200) /10.0f );
        
        if (data.length != 20) {
            return self;
        }
        uint8_t * dataBytes = (uint8_t *)[data bytes];
        
        self.subObjArray = [NSMutableArray new];
        
        uint32_t lastTs = *((uint32_t *)(dataBytes + 2));
        self.daTimeStamp = lastTs;
        
        for (int i = 0; i < 5; i++) {
            
            uint32_t ts = lastTs - (4-i)*60;
            uint8_t valByte = dataBytes[i+6];
            
            CAnAlgSkinTempAsleepSub *sub = [[CAnAlgSkinTempAsleepSub alloc]init];
            sub.timeStamp = ts;
            sub.skinTempValue = @((valByte +200)/10.f);
            [self.subObjArray addObject:sub];
        }
        
    }
    return self;
}


@end

@implementation CAnAlgSkinTempAsleepSub



@end
